/*******************************************************************************
 * Copyright (c) 2011 Irineu Martins de Lima Moura (imlm2).
 * This file is part of JBeat.
 * 
 *     JBeat is free software: you can redistribute it and/or modify
 *     it under the terms of the GNU Lesser General Public License as published by
 *     the Free Software Foundation, either version 3 of the License, or
 *     (at your option) any later version.
 * 
 *     JBeat is distributed in the hope that it will be useful,
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *     GNU Lesser General Public License for more details.
 * 
 *     You should have received a copy of the GNU Lesser General Public License
 *     along with JBeat.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * Contributors:
 *     Irineu Martins de Lima Moura (imlm2) - initial API and implementation
 ******************************************************************************/
package br.ufpe.cin.imlm2.util;

import java.io.IOException;
import java.io.Writer;

public class FormattedIO {

	public static final String tab = "\t";

	public static void printlnTabbed(int tabNumber, Object msg) {
		printTabbed(tabNumber, msg + SystemProperties.LINE_SEPARATOR);
	}

	public static void printTabbed(int tabNumber, Object msg) {
		if (tabNumber < 0)
			throw new IllegalArgumentException(
					"Numero de tabulacoes deve ser maior ou igual a zero");
		String tabs = "";
		for (int i = 0; i < tabNumber; i++) {
			tabs = tabs + tab;
		}
		System.out.print(tabs + msg);
	}

	public static void printlnTabbed(int tabNumber, Object msg, Writer r)
			throws IOException {
		printTabbed(tabNumber, msg + SystemProperties.LINE_SEPARATOR, r);
	}

	public static void printTabbed(int tabNumber, Object msg, Writer r)
			throws IOException {
		if (tabNumber < 0)
			throw new IllegalArgumentException(
					"Numero de tabulacoes deve ser maior ou igual a zero");
		String tabs = "";
		for (int i = 0; i < tabNumber; i++) {
			tabs = tabs + tab;
		}
		r.write(tabs + msg);
	}
}
